 <?php

 // START GET DATA THEO GET  METHOD-------------
 	$id = alphaID($_GET['id'], true);
	$data['category']=cache_get_category($id);
	$order=" id desc";
	$url="";
	if(isset($_GET['type'])){

		switch($_GET['type']){
				case 'picture': $where=' where is_image=1 and cat_id='.$id;break;
				case 'video': $where=' where is_video=1 and cat_id='.$id;break;
				case 'text': $where=' where is_text=1 and cat_id='. $id;break;
				
		}
	}else{ $where=' where cat_id='.$id; }
	
	if(isset($_GET['ext'])){
		
		switch($_GET['ext']){
			case 'views':
			case 'likes':
			case 'comments':
			$order= $_GET['ext']." ".$_GET['sort'];
			break;
			case "date":
			$order= "id ".$_GET['sort'];
		
		}
	$url="";
	}
	
	
	$cache=new Cache;
	$sql ="select id,cat_id,post_id,username,id_album ,is_image,is_video,is_text from index_post ".$where." order by ".$order;
	
	$sql2="select id from index_post ".$where;

	$pager = new Pagination($sql,LOAD_ITEMS,4,$url,5,"post");

	$pager->setDebug(false);
	$data[info] = $pager->paginate($cache,$sql2);
	$data[nav]	= $pager->renderFullNav();
	$data['page']=$pager->get_num_page();
	
	// END OF GET DATA THEO GET MOTHOD
	if($data['page']<$_GET['page']){
		$data[info]='';
	}
	
	// NEU GET PAGE = 1 HOAC GET PAGE % 5 ==0 , THI RENDER LAI DATA
	if(!isset($_GET['page']) || $_GET['page']==1 || $_GET['page']% LOAD_TIME ==0){
			
			
		
			$data1[title]=web_title($data['category']['name'],'category');

			loadview('template/header',$data1);
			
			if($_SESSION['mobile']!=0){
				loadview("news/list_category",$data);
			}else
			if($_SESSION['list_news_list'] == 1){
				loadview("news/list_category_list",$data);
			}else{
				loadview("news/list_category_grid",$data);
			}
		//loadview('template/right');
	}else{
		exit();
	
	
	
	}



	

?>